package design.pattern.Lu19VisitorPattern;

import lombok.Data;

/**
 * @program JavaBase
 * @description: 访问者模式
 *  未使用设计模式
 * @author: zhanglu
 * @create: 2020-05-07 16:05:00
 */
public class VisitorPattern01 {

    public static void main(String[] args) {
        CommonEmployee commonEmployee = new CommonEmployee();
        commonEmployee.setName("张三");
        commonEmployee.setSalary("1000");
        commonEmployee.setJob("拧螺丝、搬砖");
        commonEmployee.report();

        Manager manager = new Manager();
        manager.setName("里斯");
        manager.setSalary("10000");
        manager.setPerformance("拿到xxx项目");
        manager.report();

    }

}

@Data
abstract class Employee{

    private String name;
    private String salary;

    public final void report(){
        String info = "姓名：" + this.name + "\t薪资：" + this.salary;
        info += this.getOtherInfo();
        System.out.println(info);
    }

    protected abstract String getOtherInfo();

}

@Data
class CommonEmployee extends Employee{

    private String job;

    @Override
    protected String getOtherInfo() {
        return "\t工作：" + this.job;
    }

}

@Data
class Manager extends Employee{

    private String performance;

    @Override
    protected String getOtherInfo() {
        return "\t业绩：" + this.performance;
    }
}
